import React, { Component } from 'react'
import style from './list_header.module.css'
import axios from 'axios'
import {connect} from "react-redux"
 class List_header extends Component {
    state = {
        citylist:[],
        time:''
    }
    changeInput = () => {
        console.log(this.name.value)
    
    }
    search=()=>{
        clearTimeout(this.state.time)
        const headerJSON = {
            "Content-Type": "application/json;charset=UTF-8"
        };
        this.state.time = setTimeout(()=>{
            console.log(this.name.value)
            axios({
                url: "/shop/search",
                method: 'post',
                headers: headerJSON,
                data:{
                    name:this.name.value
                }
            }).then(res=>{
                console.log(res)
                this.props.changeShopList(res.data.lists)   
            })
        },200)
        
    }
    componentDidMount() {
       
    }
    
    render() {
        let dizhi = this.props.dizhi
        // console.log(this.props)
        return (
            <div className={style.list_header}>
                <div className={style.list_header_left}>
                    <div onClick={this.props.changeChouti} className={style.jilian}>
                    {dizhi.name}
                        </div><span className={style.shugang}>|</span><input ref={node => this.name = node} placeholder="请输入楼盘名称" className={style.search} /> <button onClick={this.search} className={style.btn}>搜索</button>
                </div>
                <div className={this.state.flag ? style.aaa : style.bbb}>地图</div>
                
            </div>
        )
    }
}



 
export default connect(
    state => ({
        dizhi : state.citylist
    }),
)(List_header)




